package com.tedu._04mybatis.mapper;

import com.tedu._04mybatis.pojo.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface WeiBoMapper {

//    @Insert("INSERT INTO weibo(content,created,user_id) "+
//            "VALUES(#{content},#{created},#{userId})")

    int insert(WeiBo weibo);

    //@Delete("DELETE FROM weibo where id=#{id}")
    int deleteById(Integer id);

//    @Update("UPDATE weibo " +
//            "SET content=#{content},created=#{created},user_id=#{userId} " +
//            "WHERE id=#{id}"
//    )
    int updateById(WeiBo weibo);
//从数据库里面查询出来的数据 放到 实体类Weibo上面 因为数据库字段名user_id 和 实体类属性名不一致userId 所以放不上 需要别名
//    @Select("SELECT id,content,created,user_id userId " +
//            "FROM weibo " +
//            "WHERE id = #{id}")
    WeiBo selectById(Integer id);
//    @Select("SELECT id,content,created,user_id userId " +
//            "FROM weibo ")
    List<WeiBo> selectAll();
//    @Select("SELECT content,created " +
//            "FROM weibo "+
//            "WHERE id = #{id}")
    WeiboVO1 selectWeibo(Integer id);
//    @Select("SELECT content,created,user_id userId " +
//            "FROM weibo ")
    List<WeiboVO2> selectAllWeiboVO2();

    int dynamicUpdate(WeiBo weibo);

    int dynamicDelete(Integer[] ids);

    int dynamicDelete2(List<Integer>ids);

    WeiboVO3 selectWeiboVO3ById(Integer id);


    List<WeiboVO3> selectAllWeiboVO3();

    int countWeibo();

}
